<template>
  <default-layout>
    <header-back :text="title" slot="header"></header-back>
    <div slot="main">
      <div class="info">
        <span class="sub">请立即支付完成报名</span>
        <span class="title">{{order.totalFee}}元</span>
        <span class="sub">{{order.month || order.name}}</span>
      </div>
      <div class="list">
        <div class="item" @click="radio = 1">
          <div class="left">
            <i class="xffont xf-zhifubao"></i>
            <span class="way-name">支付宝</span>
          </div>
          <div class="right">
            <yd-radio-group v-model="radio" color="#2e71c9">
              <yd-radio :val="1">&nbsp;</yd-radio>
            </yd-radio-group>
          </div>
        </div>
        <div class="item" @click="radio = 2">
          <div class="left">
            <i class="xffont xf-weixin"></i>
            <span class="way-name">微信</span>
          </div>
          <div class="right">
            <yd-radio-group v-model="radio" color="#2e71c9">
              <yd-radio :val="2">&nbsp;</yd-radio>
            </yd-radio-group>
          </div>
        </div>
      </div>
      <div class="next">
        <mt-button size="large" type="primary" @click="onSubmit">确定支付</mt-button>
      </div>
    </div>
  </default-layout>
</template>
<script>
  import HeaderBack from '../../../components/header-back/header-back.vue'
  import DefaultLayout from '../../../layouts/default-layout/default-layout'
  import {mapGetters} from 'vuex'

  export default {
    components: {DefaultLayout, HeaderBack},
    computed: {
      ...mapGetters([
        'order'
      ])
    },
    data() {
      return {
        radio: 0,
        detail: {},
        title: ''
      }
    },
    methods: {
      onSubmit() {
        if (this.$route.query.type === 'party') {
          this.pay1()
        } else {
          this.pay2()
        }
      },
      // 党员缴费支付
      pay1() {
        this.$post('/admin/person/sapi/party/pay/save/success', {
          id: this.order.id,
          orderNumber: this.order.orderNumber,
          payMethod: '0', // 0微信，1支付宝，2现金
          originalResult: JSON.stringify({
            message: '支付成功'
          })
        }).then(res => {
          this.$router.replace({
            name: 'paySuccess',
            query: this.$route.query
          })
        })
      },
      // 继续教育支付
      pay2() {
        this.$post('/admin/person/sapi/education/continuing/save/pay/info', {
          id: this.order.id,
          orderNumber: this.order.orderNumber,
          payMethod: '0', // 0微信，1支付宝，2现金
          originalResult: JSON.stringify({
            message: '支付成功'
          })
        }).then(res => {
          this.$router.replace({
            name: 'paySuccess',
            query: this.$route.query
          })
        })
      }
    },
    created() {
      if (!this.order) {
        this.$router.back()
        return
      }
      switch (this.$route.query.type) {
        case 'party':
          this.title = '党员缴费'
          break
        default:
          this.title = '继续教育缴费'
      }
    }
  }
</script>
<style lang="scss" scoped>
  @import "../../../common/style/variable";

  .info {
    padding: .8rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    .sub {
      font-size: .28rem;
      color: #999;
    }
    .title {
      font-size: .5rem;
      color: #333;
      font-weight: bold;
    }
    span {
      margin: .15rem 0 0 0;
    }
  }

  .list {
    background: #fff;
    .xf-zhifubao {
      color: #07a0f8;
      font-size: .5rem;
    }
    .xf-weixin {
      color: #3baf34;
      font-size: .5rem;
    }
    .item {
      padding: .2rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .left {
        display: flex;
        align-items: center;
        .way-name {
          margin: 0 0 0 .15rem;
        }
      }
      &:not(:last-child) {
        border-bottom: 1px solid #ededed;
      }
    }
  }

  .next {
    position: fixed;
    bottom: 1px;
    left: 0;
    width: 100%;
  }
</style>
